#include "request-creator-client.hh"

#include "request-client.hh"

boost::shared_ptr<Request>
RequestCreatorClient::operator() (RequestType rqtype, const std::string& data)
{
  if ((int) rqtype != 7)
    std::cout << "REQUEST RECEIVED = " << (int) rqtype << std::endl;

  switch (rqtype)
  {
  case RType::CONNECTION:
    return boost::shared_ptr<ConnectionClient> (new ConnectionClient (data));
  case RType::ASK_MAP:
    return boost::shared_ptr<AskMapClient> (new AskMapClient (data));
  case RType::GET_OBJECT:
    return boost::shared_ptr<GetObject> (new GetObjectClient (data));
  case RType::TEXT:
    return boost::shared_ptr<Text> (new Text (data));
  case RType::UPDATE_OBJ:
    return boost::shared_ptr<UpdateObj> (new UpdateObj (data));
  case RType::GAME_MODE:
    return boost::shared_ptr<GameMode> (new GameMode (data));
  case RType::GAME_ZONE:
    return boost::shared_ptr<GameZone> (new GameZone (data));
  default:
    std::cout << "unhandled request: " << rqtype << std::endl;
    return boost::shared_ptr<Request> ();
  }
}

boost::shared_ptr<Request>
RequestCreatorClient::on_error ()
{
  std::cout << "connection lost" << std::endl;
  return boost::shared_ptr<Request> ();
}
